package com.mobi.Survey.map;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.google.android.gms.internal.bu;
import com.mobi.Survey.lib.activities.AbstractScreen;

public class AddressDialogue extends AbstractScreen {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		hideTitle = true;
		super.onCreate(savedInstanceState);

		if (getIntent() != null && getIntent().getExtras() != null) {

			Bundle bundle = getIntent().getExtras();
			String strCountry = bundle.getString("country");
			String strState = bundle.getString("state");
			String strCity = bundle.getString("city");
			String strZip = bundle.getString("zip");
			
			((EditText) findViewById(R.id.editCountry)).setText(strCountry);
			((EditText) findViewById(R.id.editZip)).setText(strZip);
			((EditText) findViewById(R.id.editState)).setText(strState);
			((EditText) findViewById(R.id.editCity)).setText(strCity);

		}

	}

	@Override
	protected void initUiVars() {

	}

	@Override
	protected int getLayoutId() {
		// TODO Auto-generated method stub
		return R.layout.dialogue_address;
	}

	@Override
	protected void onRelease() {

	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
		setResult(RESULT_CANCELED);
		finish();
	}

	public void onClick(View v) {
		if (v.getId() == R.id.btnOkAddress) {
			String country = ((EditText) findViewById(R.id.editCountry)).getText().toString();
			String zip = ((EditText) findViewById(R.id.editZip)).getText().toString();
			String state = ((EditText) findViewById(R.id.editState)).getText().toString();
			String city = ((EditText) findViewById(R.id.editCity)).getText().toString();

			Intent i = new Intent();
			i.putExtra("country", country);
			i.putExtra("zip", zip);

			i.putExtra("state", state);

			i.putExtra("city", city);

			setResult(RESULT_OK, i);
			finish();

		} else if (v.getId() == R.id.btnCancelAddress) {
			setResult(RESULT_CANCELED);
			finish();
		}
	}

}
